import 'package:flutter/material.dart';
import 'package:flutter_app/openeye/widget/app_bar.dart';

class ContainerTest extends StatelessWidget {
  const ContainerTest({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return materialPage(
        appBar: appBar("定位装饰组件测试",backButton: BackButton(color: Colors.black,onPressed: (){
          Navigator.pop(context,"从Container_test返回");
        })), page: fractionallySizedBoxPage());
  }

  createContainerPage() {
    return Container(
      alignment: Alignment(0,-1),
      padding: EdgeInsets.all(10),
      decoration: const BoxDecoration(
          shape: BoxShape.rectangle,
          borderRadius: BorderRadius.all(Radius.circular(20)),
          color: Colors.blue
      ),
      transform: Matrix4.rotationY(0.5),
      child: Text("文本显示测试",style: TextStyle(color: Colors.white),),
    );
  }

  sizedBoxPage() {
    return SizedBox(
      height: double.infinity,
      width: double.infinity,
      child: Container(
        alignment: Alignment.center,
        color: Colors.blue,
        child: Text("sizedBoxPage"),
      ),
    );
  }

  aspectRatio() {
    return Container(
      height: 300,
      width: 300,
      color: Colors.blue,
      alignment: Alignment.center,
      child: AspectRatio(
        aspectRatio: 2/1,
        child: Container(color: Colors.red,),
      ),
    );
  }

  fractionallySizedBoxPage() {
    return Container(
      height: 200,
      width: 200,
      alignment: Alignment.topLeft,
      color: Colors.blue,
      child: FractionallySizedBox(
        widthFactor: 0.5,
        heightFactor: 0.3,
        child: Container(
          alignment: Alignment.topLeft,
          color: Colors.red,
          child: Text("文本文档",style: TextStyle(fontSize: 20,color: Colors.white),),
        ),
      ),
    );
  }
}
